package com.evildog.workspace.system.application.controller;

import com.evildog.workspace.common.result.Result;
import com.evildog.workspace.common.result.ResultGenerator;
import com.evildog.workspace.system.application.bo.UiPermissionBO;
import com.evildog.workspace.system.application.convert.UiPermissionConvert;
import com.evildog.workspace.system.application.service.UiPermissionService;
import com.evildog.workspace.system.application.vo.UiPermissionVO;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/ui-permissions")
@AllArgsConstructor
@Api(tags = "查询ui权限的接口")
public class UiPermissionController {

    private UiPermissionService uiPermissionService;

    /**
     * 查询用户的所有前端权限
     * 用于前端验证权限
     */
    @GetMapping
    public Result<List<UiPermissionVO>> getAllUiPermissionsForAuth(){
        List<UiPermissionBO> allUiPermissions = uiPermissionService.getAllUiPermissions();
        return ResultGenerator.success(UiPermissionConvert.INSTANCE.convert(allUiPermissions));
    }

}
